<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
define('FPDF_FONTPATH','../../Lib/fpdf/font/');
include_once '../../Lib/fpdf/fpdf.php';
include_once '../../Lib/pivote.php';
include_once '../../Lib/class.funcLab.php';
include_once '../../Lib/class.session.php';
include_once '../../Lib/class.setter.php';

class PDF extends FPDF
{
    function Header(){
        //$this->Image('../../images/logo_salud.png',10,6,40, 27);
        $this->SetFont('Times', '', 10);
        $this->Image('../../images/logo_salud.png',10,6,40, 27);
        $this->SETXY(100,13);
        $this->Cell(10,1,'IMPRESION DE CEDULA DEL PACIENTE',0,1);
        $this->SETXY(120,22);
        $this->Cell(10,1,'('.date("d/m/Y H:i:s").')',0,1);
        $this->Ln(12);
   }
   function datGenerales($datos){
       $this->tituloSeccion('DATOS GENERALES');
       $this->SetFillColor(222,217,217);
       $this->SetTextColor(0, 0, 0);
       $this->Cell(10,4,'Folio',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(35,4,$datos['cFolio'],0,1,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(35,4,'APELLIDO PATERNO',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(35,4,$datos['cPaterno'],0,0,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(35,4,'APELLIDO MATERNO',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(35,4,$datos['cMaterno'],0,0,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(15,4,'NOMBRE',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(20,4,$datos['cNombre'],0,1,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(10,4,'CURP',0,0,'L',true);
       $this->SetFillColor(255,255,255);       
       $this->Cell(30,4,$datos['curp'],0,0,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(35,4,'FECHA DE NACIMIENTO',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(25,4,$datos['FechaNac'],0,1,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(25,4,'NACIONALIDAD',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(25,4,$datos['cNacionalidad'],0,1,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(38,4,'ENTIDAD DE NACIMIENTO',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(25,4,$datos['entidad'],0,1,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(25,4,'SEXO:*',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(25,4,$datos['cSexo'],0,0,'L',true);
       if($datos['cSexo']=='FEMENINO'){
            $this->SetFillColor(222,217,217);
            $this->Cell(30,4,'ESTA EMBARAZADA:',0,0,'L',true);
            $this->SetFillColor(255,255,255);
            $this->Cell(25,4,$datos['Embarazo'],0,1,'L',true);
       }
       $this->SetFillColor(222,217,217);
       $this->Cell(38,4,'ENTIDAD DE RESIDENCIA:',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(30,4,$datos['entidad'],0,0,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(30,4,'MUNICIPIO:',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(25,4,$datos['cMunicipio'],0,1,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(30,4,'CALLE:',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(25,4,$datos['calle'],0,0,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(38,4,'NUMERO:',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(8,4,$datos['cCalle_numero'],0,1,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(38,4,'ENTRE CALLES:',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(25,4,$datos['calle1'].','.$datos['calle2'],0,1,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(15,4,'COLONIA:',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(40,4,$datos['cColonia'],0,0,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(10,4,'CP:',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(20,4,$datos['cp'],0,0,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(38,4,'TELEFONO:',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(25,4,$datos['telefono'],0,1,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(50,4,'SE RECONOCE COMO INDIGENA?:',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(8,4,$datos['Indigena'],0,0,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(54,4,'HABLA ALGUNA LENGUA INDIGENA?:',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(8,4,$datos['LIndigena'],0,1,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(30,4,'OCUPACION:*',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(8,4,$datos['ocupacion'],0,1,'L',true);
       $this->Ln(1);

   }

   function datClinicos($datos){
       $this->tituloSeccion('DATOS CLINICOS');
       $this->SetFillColor(222,217,217);
       $this->SetTextColor(0, 0, 0);
       $this->Cell(35,4,'SERVICIO:*',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(35,4,$datos['servicio'],0,1,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(45,4,'FECHA INGRESO AL HOSPITAL',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(25,4,$datos['FechaIngreso'],0,0,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(45,4,'FECHA INICIO DE SINTOMAS',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(13,4,$datos['FechaInicial'],0,1,'L',true);
       


       $this->SetFillColor(222,217,217);
       $this->Cell(45,4,'DIAGNOSTICO PROBABLE:',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(13,4,$datos['diagnostico'],0,1,'L',true);
   }

   function tratamiento($datos){
       $this->tituloSeccion('TRATAMIENTO');
       $this->SetTextColor(0, 0, 0);
       $this->SetFillColor(222,217,217);
       $this->Cell(110,4,'DESDE EL INICIO DE LOS SINTOMAS HA RECIBIDO ALGUN TRATAMIENTO?:*',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(5,4,$datos['RecibioTratamiento'],0,1,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(110,4,'SE INICIA TRATAMIENTO CON ANTIMICROBIANOS?:*',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(5,4,$datos['TratamientoAntimicrobianos'],0,1,'L',true);
       $this->SetFillColor(222,217,217);
       $this->Cell(110,4,'SE INICIA TRATAMIENTO CON ANTIVIRALES?:*',0,0,'L',true);
       $this->SetFillColor(255,255,255);
       $this->Cell(5,4,$datos['TratamientoAntiviral'],0,1,'L',true);
   }

   function antEpidemio(){
     $this->tituloSeccion('');
   }

   function datLaboratorio(){
     $this->tituloSeccion('LABORATORIO');
   }

   function evolucion(){
     $this->tituloSeccion('EVOLUCION');
   }

   function tituloSeccion($txt)
   {
        $this->SetFont('Arial','B', 8);
        $this->SetFillColor(255,168,0);
        $this->SetTextColor(10,71,138);
        $this->Cell(0, 6, $txt, 1,1,'C',true);
        $this->Ln(3);
   }

   function Footer(){

   }
}
import_request_variables("g,P");
$pdf=new PDF();
$session= new session();
$usuario=new setter();
$paciente= new funcLab(Srv, Usr, Pass, base);

$id_user= $_SESSION['id_usuario'];
$id_unidad 	= $_SESSION['idunidad'];
$id_sector 	= $_SESSION['idsector'];
$id_delegacion  = $_SESSION['iddelegacion'];
$id_entidad     = $_SESSION['identidad'];
$nUnidad	= $_SESSION['nombreUnidad'];
$nUsuario	= $_SESSION['nombreUsuario'];
$nPerfil	= $_SESSION['perfil'];
$nRol           = $_SESSION['rol'];
$nEntidad 	= $_SESSION['nEntidad'];

$usuario->setnUnidad($nUnidad);
$usuario->setnUsuario($nUsuario);
$datos=$paciente->datImpCedula($id_principal);

$pdf->AddPage();
$pdf->datGenerales($datos);
$pdf->datClinicos($datos);
$pdf->tratamiento($datos);
$pdf->datLaboratorio();
$pdf->evolucion();
$pdf->Output();
?>